package com.lzw.service.impl.admin;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lzw.mapper.admin.SupplierReturnsManage2Mapper;
import com.lzw.pojo.SupplierReturns;
import com.lzw.service.admin.SupplierReturnsManage2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class SupplierReturnsManage2ServiceImpl implements SupplierReturnsManage2Service {

    @Autowired
    private SupplierReturnsManage2Mapper supplierReturnsManage2Mapper;

    @Override
    public List<SupplierReturns> list(Integer pageNum, Integer pageSize, String supplier, String medicine, LocalDate returnDate) {
        PageHelper.startPage(pageNum,pageSize);
        List<SupplierReturns> list = supplierReturnsManage2Mapper.list(supplier, medicine, returnDate);
        Page<SupplierReturns> supplierReturns = (Page<SupplierReturns>) list;
        return supplierReturns;    }

    @Override
    public void add(SupplierReturns supplierReturns) {
        supplierReturns.setReturnDate(LocalDate.now());
        supplierReturnsManage2Mapper.add(supplierReturns);
    }

    @Override
    public void update(SupplierReturns supplierReturns) {
        supplierReturnsManage2Mapper.update(supplierReturns);
    }
}
